Capture control topic
The host captures what is under its glass by painting that part of the tree a second time, into a picture of its own. Most of the time that is exactly right. GlassProxy is for the subtrees where it is not: it tells the capture what a subtree is, and changes nothing in the frame the user sees.
| Declaration | The capture… | For |
|---|---|---|
| GlassProxy.replace | paints a GlassProxyPainter's stand-in instead of the subtree | a video, a camera preview, a map or any platform view: they record nothing, and the glass would show a hole |
| GlassProxy.hidden | leaves the subtree out, and does not run its paint |
a subtree the glass should not show, or one whose paint has side effects |
| GlassProxy.opaque | takes the subtree as covering its own box | a full-bleed image or panel: the capture stops looking under it |
| GlassProxy.verbatim | exempts the subtree from the shadow filter | a highlight blurred through a MaskFilter on purpose |
A stand-in for a video
Stack(
fit: StackFit.expand,
children: <Widget>[
GlassProxy.replace(
painter: const GradientProxyPainter(
LinearGradient(colors: <Color>[Color(0xFF1B1F2A), Color(0xFFFF9F0A)]),
),
child: videoPlayer, // a platform view
),
const Positioned(left: 16, right: 16, bottom: 16, child: GlassBar(child: Text('Live'))),
],
)
Two stand-ins come with the package, SolidProxyPainter and GradientProxyPainter; anything else is a GlassProxyPainter of your own:
class PosterProxyPainter extends GlassProxyPainter {
const PosterProxyPainter(this.poster);
final ui.Image poster;
@override
void paint(Canvas canvas, Size size) =>
paintImage(canvas: canvas, rect: Offset.zero & size, image: poster, fit: BoxFit.cover);
@override
bool shouldRepaint(PosterProxyPainter oldPainter) => oldPainter.poster != poster;
}
A stand-in changes what the glass sees, not when the host captures: a video that composites a new frame is still a change. Live, with each declaration: Capture control.
Classes
- GlassProxy Capture control
- Declares what its subtree is in the glass proxy.
- GlassProxyPainter Capture control
- Draws a stand-in for a subtree in the proxy, for GlassProxy.replace.
- GradientProxyPainter Capture control
- A stub of one gradient. Keeps a local mean where a flat colour would not — which is the axis a blur cannot restore (D29): a low-pass removes what is above its cutoff and cannot bring back a mean that is no longer there.
- RenderGlassProxy Capture control
- The marker the proxy pass reads. In the real frame it is a plain proxy box.
- SolidProxyPainter Capture control
- A stub of one flat colour — the cheapest thing that stands for a subtree.
Enums
- GlassProxyRole Capture control
- The four declarations, in the order of how much they subtract.